package com.miku.blog.utils;

import com.miku.blog.domain.pojo.LoginUser;
import com.miku.blog.domain.pojo.SystemConstance;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author shkstart
 * @create ${}YEAR-06-07 2:44
 */
public class RedisCacheUtils {


    public static List<LoginUser> getLoginUser(RedisCache redisCache){

        Collection<String> keys = redisCache.keys(SystemConstance.REDIS_LOGINUSER_KEY + SystemConstance.REDIS_PATTERN_KEY);

        List<LoginUser> userList = keys.stream()
                .map(key -> (LoginUser) redisCache.getCacheObject(key))
                .collect(Collectors.toList());
        return userList;
    }

}
